home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Memphis Amiga Group / MAG DOS 2.0 Utilities Disk 01 (1991-09)(Memphis Amiga Group).zip / MAG DOS 2.0 Utilities Disk 01 (1991-09)(Memphis Amiga Group).adf / KickReboot / KickReboot.c < prev    next >
C/C++ Source or Header  |  1990-07-16  |  2KB  |  74 lines

  1. /* Adds KickReboot Menu to Tools Menu on Workbench 2.0                   */
  2. /* to give a choice to boot a different KickStart without powering       */
  3. /* down the system on A3000 machines who loads Kickstart from Harddisk   */
  4. /* This time there is no way to remove it (but why ??)                   */
  5. /* This code is released to the Public Domain, do with it what you want  */
  6. /* Author Joachim Bremer, West Germany, I can be reached at Bix: bremer  */
  7. /* MacNet: prismaqt, attn Joachim Bremer                                 */
  8.  
  9. /* compile with : lc -v -O KickReboot                                    */
  10. /* assemble with: asm -iinclude: KickBoot.a                              */
  11. /* link with    : blink lib:cback.o+KickReboot.o+KickBoot.o to KickMenu
  12.             lib:lc.lib+lib:amiga.lib                         */
  13.  
  14. /* for use without pragmas you must have at least access to workbench.h  */
  15. /* and amiga.lib from 1.4 alpha or higher.                               */
  16.  
  17.  
  18. #include "exec/types.h"
  19. #include "exec/ports.h"
  20. #include "workbench/workbench.h"
  21. #include "stdio.h"
  22. #include "proto/exec.h"
  23.  
  24. long _BackGroundIO = 0;
  25. long _stack = 4000;
  26. char *_procname = "RebootWbMenu";
  27. long _priority = -20;
  28.  
  29. CPTR WorkbenchBase;
  30.  
  31. extern void KickReboot();
  32.  
  33. /* not used if include 1.4 alpha or newer is available */
  34.  
  35. struct AppMenuItem {
  36.         struct Node ami_Node;
  37.         void *ami_Ptr;
  38.         struct MsgPort *ami_MsgPort;
  39.         ULONG ami_UserData;
  40.         ULONG ami_ID;
  41. };
  42.  
  43.  
  44.  
  45. #pragma libcall WorkbenchBase AddAppMenuItem 48 981004
  46. #pragma libcall WorkbenchBase RemoveAppMenuItem 4e 801
  47.  
  48. VOID
  49. _main(void)
  50. {
  51.     struct AppMenuItem *app;
  52.     struct AppMenuItem *AddAppMenuItem(ULONG,ULONG,char *,struct MsgPort *);
  53.     struct MsgPort *port;
  54.     struct IntuiMessage *msg;
  55.     WorkbenchBase = OpenLibrary("workbench.library",36);
  56.     if (!WorkbenchBase) {
  57.     exit(9);
  58.     }
  59.     if (!(port = CreatePort("KickReboot",0L))) {
  60.     CloseLibrary(WorkbenchBase); exit(9); }
  61.     app = AddAppMenuItem(0,0,"KickReboot",port);
  62.     for (;;) {
  63.     WaitPort(port);
  64.     if(msg = (struct IntuiMeassage *) GetMsg(port)) break;
  65.     }
  66.     ReplyMsg((struct msg *) msg);
  67.     Delay (50);
  68.     KickReboot();
  69. /* only for sake of a good programmer ..... code never reaches here */
  70.     DeletePort(port);
  71.     RemoveAppMenuItem(app);
  72.     CloseLibrary(WorkbenchBase);
  73. }
  74.